package cn.com.bluemoon.daps.standard.controller.api;

import cn.com.bluemoon.daps.api.standard.RemoteStandardIndexService;
import cn.com.bluemoon.daps.common.constant.ServiceNameConstants;
import cn.com.bluemoon.daps.common.datascope.IgnorePermission;
import cn.com.bluemoon.daps.common.domain.ResultBean;
import cn.com.bluemoon.daps.standard.entity.DapStandardIndex;
import cn.com.bluemoon.daps.standard.service.DapStandardIndexService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 服务接口生产类-内部调用
 *
 * @author Jarod.Kong
 */
@Api(tags = {"FeignClient服务-标准服务注入Api"})
@RestController
@RequestMapping(ServiceNameConstants.DapsApiStandard.API_INDEX_STD)
@IgnorePermission(name = "服务注册-标准指标服务")
public class DapsStandardIndexApi implements RemoteStandardIndexService {
    @Resource
    private DapStandardIndexService standardIndexService;

    @Override
    public ResultBean<DapStandardIndex> getById(String id) {
        return ResultBean.ok(standardIndexService.getById(id));
    }

    @Override
    public ResultBean<Boolean> relatedBizLineId(Integer bizLineId) {
        LambdaQueryWrapper<DapStandardIndex> eq = standardIndexService.bmLambdaQuery().eq(DapStandardIndex::getBizLineId, bizLineId);
        return ResultBean.ok(standardIndexService.count(eq) > 0);
    }
}
